#define layout()
#@_jsscss()
<title>#(session.WXACCOUNT.name)</title>
<style type="text/css">
	.w3000{
		margin-right: 50px;
	}
</style>
</head>
<body>
<div class="centerMain">
        <div class="mt10 ui-form" style="display: flex;">
        		<div class="ui-form-item ui-border-b" style="padding: 15px 10px;">
            	<img src="/wx/images//express-icon.png" alt="alt" style="width:48px;" title="title" />
            </div>
            <div class="ui-form-item ui-border-b" style="line-height:24px;padding: 15px 16px;width: 100%;" id="sendinfo">
                <ul style="font-family: 微软雅黑;font-size: 16px;" ><lable id="sendname">#(session.ADDMAP.sendname ?? "")</lable><lable style="padding-left: 20px;" id="sendphone">#(session.ADDMAP.sendphone ?? "")</lable></ul>
                #if(session.BNORDER)
                 <ul style="color:#999999;font-size: 16px;"><lable id="sendcard">#(session.ADDMAP.sendcard ?? "")</lable></ul>
               #end
                 <ul style="color:#999999;font-size: 16px;"><lable id="sendadd">#(session.ADDMAP.sendadd ?? "")</lable></ul>
            </div>
        </div>
        <div class="ui-form" style="margin-top:1px;display: flex;">
        		<div class="ui-form-item ui-border-b" style="float:left;padding: 15px 10px;">
            	<img src="/wx/images//addressee-icon.png" alt="alt" style="width:48px;" title="title" />
            </div>
            <div class="ui-form-item ui-border-b" style="line-height:24px;padding: 15px 10px;width: 100%; " id="receiveinfo">
                <ul style="font-family: 微软雅黑;font-size: 16px;"><lable id="receivename">#(session.ADDMAP.receivename ?? "")</lable><lable style="padding-left: 20px;" id="receivephone">#(session.ADDMAP.receivephone ?? "")</lable></ul>
                #if(session.BNORDER)
                <ul style="color:#999999;font-size: 16px;"><lable id="receivecard">#(session.ADDMAP.receivecard ?? "")</lable></ul>
                #end
                <ul style="color:#999999;font-size: 16px;"><lable id="receiveadd">#(session.ADDMAP.receiveadd ?? "")</lable></ul>
            </div>
            <div class="ui-form-item ui-border-b" style="padding: 15px 10px;float:right;">
               	<img src="/wx/images/icon-addr.png" alt="alt" style="width:48px;" title="title"  id="useradd" />
            </div>
        </div>
         <div class="mt10 ui-form">
		    		<div class="ui-form-item" style="line-height:44px;padding-left: 20px;float:left;">
		            重量(KG)
		        </div>
		        <div class="ui-form-item" style="line-height:44px;padding-left: 20px;text-align:right;float:right;width:60%;">
		            <input class="w300" style="text-align:right;padding-right:10px;padding-left:0px;" type="number" id="weight" name="weight" value="" >
		        </div>
		        <div style="clear:both;height:0px;"></div>
		</div>
		#if(session.BNORDER)
		<div class="mt10 ui-form">
		    		<div class="ui-form-item" style="line-height:44px;padding-left: 20px;float:left;">
		            时效
		        </div>
		        <div class="ui-form-item" style="line-height:44px;padding-left: 20px;text-align:right;float:right;width:70%;">
		           <div class="ui-select">
                        <select id='timetype' name="expreee_time">
                            <option  value ='103'>当日达</option>
                            <option selected value ='100'>次日达</option>
                        </select>
                 </div>
		        </div>
		        <div style="clear:both;height:0px;"></div>
		</div>
		<div class="mt10 item">
                <input type="checkbox" class="check check1" name="checkbox" id="xieyi" style="padding:0px 2px;vertical-align:bottom;">我已查看并同意<a ><li id="bbbb" style="display: inline-block;">用户条款</li></a>
        </div>
        #else
        <div class="mt10 item" style="display: none;">
                <input checked="true" type="checkbox" class="check check1" name="checkbox" id="xieyi" style="padding:0px 2px;vertical-align:bottom;">我已查看并同意<a ><li style="display: inline-block;" id="bbbb">用户条款</li></a>
        </div>
        #end
        <div class="ui-btn-wrap mt20 ui-form" style="clear:both">
            <input id="Submit1" type="button" class="ui-btn-lg ui-btn-success" onclick="return submitForm(this)" value="确认付款" />
        </div>
        #if(session.BNORDER)
        <div class="ui-btn-wrap mt20 ui-form" style="clear:both">
            <input id="Submit2" type="button" class="ui-btn-lg ui-btn-success"  value="清空收件人信息" />
        </div>
        #end
</div>
<div class="clear"></div>
</body>
<script>
	var flag = true;
	function check(flag,errmsg){
		flag = true;
		var sendname = $("lable#sendname").text();
	    	var sendphone = $("lable#sendphone").text(); 
	    	var sendadd = $("lable#sendadd").text(); 
	    	var receivename = $("lable#receivename").text();
	    	var receivephone = $("lable#receivephone").text(); 
	    	var receiveadd = $("lable#receiveadd").text();
	    	var weight = parseFloat($("#weight").val());
		//电话号码
		var reg=/^(\d{3}-)(\d{8})$|^(\d{3})(\d{8})$|^(\d{4}-)(\d{7})$|^(\d{4}-)(\d{8})$|^(\d{4})(\d{8})$/;
		var objExp=new RegExp(reg);
		if ($("#xieyi").get(0).checked) {
         // do something
		}else{
			
			return "请查看用户条款，同意后才能下单!" ;
		}
		if(!objExp.test(sendphone)){
			return "寄件人电话号码格式错误";
		}
		if ($("#xieyi").get(0).checked) {
    // do something
}else{
	
	return "请查看用户条款，同意后才能下单!" ;
}
		if(!objExp.test(receivephone)){
			return "收件人人电话号码格式错误";
		}
		if(sendname == ''){
			return "寄件人姓名不能为空";
		}
		if(receivename == ''){
			return "收件人姓名不能为空";
		}
		if(receiveadd == ''){
			return "收件人地址不能为空";
		}
		if(sendadd == ''){
			return "寄件人地址不能为空";
		}
		if(isNaN(weight)){
			return "重量必须为数字";
		}
		return "ok";
	}
	function addbind()
	{
		
		$("#bbbb").bind("click",function(){
		var sendname = $("lable#sendname").text();
	    	var sendphone = $("lable#sendphone").text(); 
	    	var sendadd = $("lable#sendadd").text(); 
	    	var receivename = $("lable#receivename").text();
	    	var receivephone = $("lable#receivephone").text(); 
	    	var receiveadd = $("lable#receiveadd").text();
	    	var expressTime = $("#timetype").val();
	    	var sendcard = $("#sendcard").val();
	    	var receivecard= $("#receivecard").val();
        window.location.href="/wxorder/toEditUserAdd?appid=#(session.appid)&state=9&sendcard="+sendcard+"&receivecard="+receivecard+"&expreee_time="+expressTime+"&sendname="+sendname+"&sendphone="+sendphone+"&sendadd="+sendadd+"&receivename="+receivename+"&receivephone="+receivephone+"&receiveadd="+receiveadd;
	    });
		$("#useradd").bind("click",function(){
		var sendname = $("lable#sendname").text();
	    	var sendphone = $("lable#sendphone").text(); 
	    	var sendadd = $("lable#sendadd").text(); 
	    	var receivename = $("lable#receivename").text();
	    	var receivephone = $("lable#receivephone").text(); 
	    	var receiveadd = $("lable#receiveadd").text();
	    	var expressTime = $("#timetype").val();
	    	var sendcard = $("#sendcard").val();
	    	var receivecard= $("#receivecard").val();
        window.location.href="/wxorder/toUserAdd?appid=#(session.appid)&sendcard="+sendcard+"&receivecard="+receivecard+"&expreee_time="+expressTime+"&sendname="+sendname+"&sendphone="+sendphone+"&sendadd="+sendadd+"&receivename="+receivename+"&receivephone="+receivephone+"&receiveadd="+receiveadd;
	    });
	    $("#sendinfo").bind("click",function(){
	    	 var sendname = $("lable#sendname").text();
	    	 var sendphone = $("lable#sendphone").text(); 
	    	 var sendadd = $("lable#sendadd").text(); 
	    	 var receivename = $("lable#receivename").text();
	    	 var receivephone = $("lable#receivephone").text(); 
	    	 var receiveadd = $("lable#receiveadd").text();
	    	 var expressTime = $("#timetype").val();
	    	var sendcard = $("#sendcard").text();
	    	var receivecard= $("#receivecard").text();
	     window.location.href="/wxorder/toEditUserAdd?appid=#(session.appid)&sendcard="+sendcard+"&receivecard="+receivecard+"&state=0&expreee_time="+expressTime+"&sendname="+sendname+"&sendphone="+sendphone+"&sendadd="+sendadd+"&receivename="+receivename+"&receivephone="+receivephone+"&receiveadd="+receiveadd;
	    });
	    $("#receiveinfo").bind("click",function(){
	    	 var receivename = $("lable#receivename").text();
	    	 var receivephone = $("lable#receivephone").text(); 
	    	 var receiveadd = $("lable#receiveadd").text(); 
	    	 var sendname = $("lable#sendname").text();
	    	 var sendphone = $("lable#sendphone").text(); 
	    	 var sendadd = $("lable#sendadd").text();
	    	 var expressTime = $("#timetype").val();
	    	var sendcard = $("#sendcard").text();
	    	var receivecard= $("#receivecard").text();
	     window.location.href="/wxorder/toEditUserAdd?appid=#(session.appid)&sendcard="+sendcard+"&receivecard="+receivecard+"&state=1&expreee_time="+expressTime+"&receivename="+receivename+"&receivephone="+receivephone+"&receiveadd="+receiveadd+"&sendname="+sendname+"&sendphone="+sendphone+"&sendadd="+sendadd;
	    });
	}
	function removebind()
	{
		$("#useradd").unbind("click");
		$("#receiveinfo").unbind("click");
		$("#sendinfo").unbind("click");
	}
	addbind();
	
	$("#Submit1").bind("click",function(){
		if(confirm("确认下单")){
			var flag = true;
			var mess="";
			mess = check(flag,mess);
			if(mess!="ok"){
				alert(mess);
				return;
			}
			var sendAddArr = $("lable#sendadd").text().split("^");
			var sendProCityDis = sendAddArr[0].split("||");
			var sendPro = sendProCityDis[0];
			var sendCity = sendProCityDis[1];
			var sendDis = sendProCityDis[2];
			var sendname = $("lable#sendname").text();
		    	var sendphone = $("lable#sendphone").text(); 
		    	var sendadd = sendAddArr[1];
		    	var receiveAddArr = $("lable#receiveadd").text().split("^");
			var receiveProCityDis = receiveAddArr[0].split("||");
			var receivePro = receiveProCityDis[0];
			var receiveCity = receiveProCityDis[1];
			var receiveDis = receiveProCityDis[2];
		    	var receivename = $("lable#receivename").text();
		    	var receivephone = $("lable#receivephone").text(); 
		    	var receiveadd =receiveAddArr[1];
		    	var weight = parseFloat($("#weight").val());
		    	var expressTime = $("#timetype").val();
		    	var sendcard = $("#sendcard").text();
	    	var receivecard= $("#receivecard").text();
		    	if(isNaN(weight)){
				weight = 0;
			}
		    	var myObject = { 
		    		"wxOrder.send_pro" : sendPro,
		    		"wxOrder.send_city" : sendCity,
		    		"wxOrder.send_dis" : sendDis,
				"wxOrder.send_name" : sendname, 
				"wxOrder.send_phone" : sendphone ,
				"wxOrder.send_add" : sendadd,
				"wxOrder.receive_card" : receivecard,
				"wxOrder.send_card" : sendcard,
				"wxOrder.receive_pro" : receivePro,
				"wxOrder.receive_city" : receiveCity,
				"wxOrder.receive_dis" : receiveDis,
				"wxOrder.receive_name" : receivename,
				"wxOrder.receive_phone" : receivephone, 
				"wxOrder.receive_add" : receiveadd,
				"wxOrder.express_time" : expressTime,
				"wxOrder.weight" : weight
			}
		    	flag = false;
	    		$("#Submit1").val("提交中");
	    		addbind();
		    	$.ajax( {
	            url: "/wxorder/addOrder?appid=#(session.appid)",
	            data: myObject,
	            type: 'POST',
	            async: false,
	            dataType: "json",
	            beforeSend: function () {
			        // 禁用按钮防止重复提交
			        $("#Submit1").attr({ disabled: "disabled" });
			    },
	            success: function (result)
	            {
	            	    if(result.state=="ok"){
	            	    	 	$("lable#receivename").text('');
						$("lable#receivephone").text(''); 
						$("lable#receiveadd").text('');
						$("#receivecard").text('');
						$("#weight").val('');
						alert("下单成功，我们将尽快安排递送员上门取件，请您耐心等待!订单号+"+result.ORDERNO);
	            	    }else{
	            		    alert(result.ERRMESSAGE);
	                }
	            }, 
	            failed: function ()
	            {
	               
	            },complete:function()
	            {
	              	$("#Submit1").removeAttr("disabled");
	              	$("#Submit1").val("确认寄件");
	            }
	        })
		}
		else{
			return false;
		}
    });
    
    $("#Submit2").bind("click",function(){
    		$("lable#receivename").text('');
	    $("lable#receivephone").text(''); 
	    $("lable#receiveadd").text('');
	    $("#receivecard").text('');
	    $("#weight").val('');
    });
</script>


</html>
#end
#@layout()